package com.zr.legalfactory.mapper;

import com.zr.legalfactory.pojo.Factory;
import com.zr.legalfactory.pojo.LegalFactorySelectVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by Administrator on 2019/6/15.
 */
@Mapper
public interface LegalFactoryMapper {

    @Select("select * from factory where fcode = #{fcode}")
     List<Factory> queryByFcode(String fcode);

    @Select("select * from factory where content = #{content}")
     List<Factory> queryByContent(String content);

    @Insert("insert into factory (lname,lcode,fcode,content,status,createTime,createName,updateTime," +
            "updateName) values (#{lname},#{lcode},#{fcode},#{content},#{status},#{createTime},#{createName},#{updateTime},#{updateName}) ")
     int addLegalFactory(Factory factory);

    @Select("select * from factory f left join legalperson l on f.fid=l.lid")
    Factory queryByFid(Integer fid);

    @Update("update factory set lname = #{lname},lcode = #{lcode} ,fcode = #{fcode}, status = #{status}, content = #{content}" +
            ",updateTime = #{updateTime},updateName = #{updateName} where fid = #{fid}")
    void updateFactory(Factory factory);


    List<Factory> queryPage(LegalFactorySelectVo legalFactorySelectVo);
    int queryCount(LegalFactorySelectVo legalFactorySelectVo);

    @Update("update factory set status = #{status} where fid = #{fid}")
    void updateStatus(Factory factory);
}
